//===-- TypeXML.def - Metadata about Type XML nodes ------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the XML type info database as written in the   
//  <ReferenceSection>/<Types> sub-nodes of the XML document. Type nodes 
//  are referred by "type" reference attributes throughout the document.
//  A type node never contains sub-nodes. 
//  The semantics of the attributes and enums are mostly self-documenting
//  by looking at the appropriate internally used functions and values.
//  The following macros are used:
//
//  NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete 
//  type of class CLASS where CLASS is a class name used internally by clang. 
//  After a NODE_XML the definition of all (optional) attributes of that type 
//  node follows.
//
//  END_NODE_XML - Closes the attribute definition of the current node.
//
//  ID_ATTRIBUTE_XML - Each type node has an "id" attribute containing a 
//  string, which value uniquely identify the type. Other nodes may refer 
//  by "type" reference attributes to this value.
//
//  TYPE_ATTRIBUTE_XML( FN ) - Type nodes may refer to the ids of other type 
//  nodes by a "type" attribute. FN is internally used by clang.
// 
//  CONTEXT_ATTRIBUTE_XML( FN ) - Type nodes may refer to the ids of their 
//  declaration contexts by a "context" attribute. FN is internally used by 
//  clang.
//
//  ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally 
//  used by clang. A boolean attribute have the values "0" or "1".
//
//  ATTRIBUTE_OPT_XML( FN, NAME ) - An optional attribute named NAME. 
//  Optional attributes are omitted for boolean types, if the value is false, 
//  for integral types, if the value is null and for strings, 
//  if the value is the empty string. FN is internally used by clang.
//
//  ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value
//  is an enumeration defined with ENUM_XML macros immediately following after 
//  that macro. An optional attribute is ommited, if the particular enum is the 
//  empty string. FN is internally used by clang.
//  
//  ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is 
//  internally used by clang.
//
//  END_ENUM_XML - Closes the enumeration definition of the current attribute.
//
//===----------------------------------------------------------------------===//

#ifndef TYPE_ATTRIBUTE_XML
#  define TYPE_ATTRIBUTE_XML( FN )     ATTRIBUTE_XML(FN, "type")
#endif

#ifndef CONTEXT_ATTRIBUTE_XML
#  define CONTEXT_ATTRIBUTE_XML( FN )  ATTRIBUTE_XML(FN, "context")
#endif


NODE_XML(QualType, "CvQualifiedType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getTypePtr())                      // the qualified type, e.g. for 'T* const' it's 'T*'
  ATTRIBUTE_OPT_XML(isConstQualified(), "const")        // boolean
  ATTRIBUTE_OPT_XML(isVolatileQualified(), "volatile")  // boolean
  ATTRIBUTE_OPT_XML(isRestrictQualified(), "restrict")  // boolean
END_NODE_XML

NODE_XML(ExtQualType, "ExtQualType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getBaseType())
  ATTRIBUTE_OPT_XML(getAddressSpace(), "adress_space")  // unsigned: Address Space ID - The address space ID this type is qualified with.
  ATTRIBUTE_ENUM_OPT_XML(getObjCGCAttr(), "objc_gc")    // GC __weak/__strong attributes
	  ENUM_XML(QualType::GCNone, "")
	  ENUM_XML(QualType::Weak, "weak")
	  ENUM_XML(QualType::Strong, "strong")
  END_ENUM_XML
END_NODE_XML

NODE_XML(BuiltinType, "FundamentalType")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_ENUM_XML(getKind(), "kind")
	  ENUM_XML(BuiltinType::Void, "void")
	  ENUM_XML(BuiltinType::Bool, "bool")
	  ENUM_XML(BuiltinType::Char_U, "char")               // not explicitely qualified char, depends on target platform
	  ENUM_XML(BuiltinType::Char_S, "char")               // not explicitely qualified char, depends on target platform
	  ENUM_XML(BuiltinType::SChar, "signed char")
	  ENUM_XML(BuiltinType::Short, "short");
	  ENUM_XML(BuiltinType::Int, "int");
	  ENUM_XML(BuiltinType::Long, "long");
	  ENUM_XML(BuiltinType::LongLong, "long long");
	  ENUM_XML(BuiltinType::Int128, "__int128_t");
	  ENUM_XML(BuiltinType::UChar, "unsigned char");
	  ENUM_XML(BuiltinType::UShort, "unsigned short");
	  ENUM_XML(BuiltinType::UInt, "unsigned int");
	  ENUM_XML(BuiltinType::ULong, "unsigned long");
	  ENUM_XML(BuiltinType::ULongLong, "unsigned long long");
	  ENUM_XML(BuiltinType::UInt128, "__uint128_t");
	  ENUM_XML(BuiltinType::Float, "float");
	  ENUM_XML(BuiltinType::Double, "double");
	  ENUM_XML(BuiltinType::LongDouble, "long double");
	  ENUM_XML(BuiltinType::WChar, "wchar_t");
	  ENUM_XML(BuiltinType::Char16, "char16_t");
	  ENUM_XML(BuiltinType::Char32, "char32_t");
	  ENUM_XML(BuiltinType::NullPtr, "nullptr_t");        // This is the type of C++0x 'nullptr'.
	  ENUM_XML(BuiltinType::Overload, "overloaded");
	  ENUM_XML(BuiltinType::Dependent, "dependent");
  END_ENUM_XML
END_NODE_XML

NODE_XML(FixedWidthIntType, "FixedWidthIntType")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_XML(getWidth(), "width")                    // unsigned
  ATTRIBUTE_XML(isSigned(), "is_signed")                // boolean
END_NODE_XML

NODE_XML(PointerType, "PointerType")    
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getPointeeType())
END_NODE_XML

NODE_XML(LValueReferenceType, "ReferenceType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getPointeeType())
END_NODE_XML

NODE_XML(RValueReferenceType, "ReferenceType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getPointeeType())
END_NODE_XML

NODE_XML(FunctionNoProtoType, "FunctionNoProtoType")
  ID_ATTRIBUTE_XML
END_NODE_XML

NODE_XML(FunctionProtoType, "FunctionType")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_XML(getResultType(), "result_type")
  ATTRIBUTE_OPT_XML(isVariadic(), "variadic")
END_NODE_XML

NODE_XML(TypedefType, "Typedef")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getDecl()->getUnderlyingType())
  ATTRIBUTE_XML(getDecl()->getNameAsString(), "name")     // string
  CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext())
END_NODE_XML

NODE_XML(ComplexType, "ComplexType")                      // C99 complex types (_Complex float etc)
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
END_NODE_XML

NODE_XML(BlockPointerType, "BlockPointerType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getPointeeType())                    // alway refers to a function type
END_NODE_XML

NODE_XML(MemberPointerType, "MemberPointerType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getPointeeType())
  ATTRIBUTE_XML(getClass(), "class_type")                 // refers to the class type id of which the pointee is a member
END_NODE_XML

NODE_XML(ConstantArrayType, "ArrayType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
  ATTRIBUTE_XML(getSize(), "size")                        // unsigned                    
  ATTRIBUTE_ENUM_OPT_XML(getSizeModifier(), "size_modifier")
	  ENUM_XML(ArrayType::Normal, "")
	  ENUM_XML(ArrayType::Static, "static")
	  ENUM_XML(ArrayType::Star, "star")
  END_ENUM_XML
  ATTRIBUTE_OPT_XML(getIndexTypeQualifier(), "index_type_qualifier")   // unsigned
END_NODE_XML

NODE_XML(IncompleteArrayType, "IncompleteArrayType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
END_NODE_XML

NODE_XML(VariableArrayType, "VariableArrayType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
  // note: the size expression is print at the point of declaration
END_NODE_XML

NODE_XML(DependentSizedArrayType, "DependentSizedArrayType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
  // FIXME: how to deal with size expression?
END_NODE_XML

NODE_XML(VectorType, "VectorType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
  ATTRIBUTE_XML(getNumElements(), "size")               // unsigned
END_NODE_XML

NODE_XML(ExtVectorType, "ExtVectorType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getElementType())
  ATTRIBUTE_XML(getNumElements(), "size")               // unsigned
END_NODE_XML

NODE_XML(TypeOfExprType, "TypeOfExprType")
  ID_ATTRIBUTE_XML
  // note: the typeof expression is print at the point of use
END_NODE_XML

NODE_XML(TypeOfType, "TypeOfType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getUnderlyingType())
END_NODE_XML


NODE_XML(RecordType, "Record")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_XML(getDecl()->getNameAsString(), "name")   // string
  ATTRIBUTE_ENUM_XML(getDecl()->getTagKind(), "kind")
    ENUM_XML(TagDecl::TK_struct, "struct")
    ENUM_XML(TagDecl::TK_union, "union")
    ENUM_XML(TagDecl::TK_class, "class")
  END_ENUM_XML
  CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext())
END_NODE_XML

NODE_XML(EnumType, "Enum")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_XML(getDecl()->getNameAsString(), "name")   // string
  CONTEXT_ATTRIBUTE_XML(getDecl()->getDeclContext())
END_NODE_XML

NODE_XML(TemplateTypeParmType, "TemplateTypeParmType")
  ID_ATTRIBUTE_XML
END_NODE_XML

NODE_XML(TemplateSpecializationType, "TemplateSpecializationType")
  ID_ATTRIBUTE_XML
END_NODE_XML

NODE_XML(QualifiedNameType, "QualifiedNameType")
  ID_ATTRIBUTE_XML
  TYPE_ATTRIBUTE_XML(getNamedType())
END_NODE_XML

NODE_XML(TypenameType, "TypenameType")
  ID_ATTRIBUTE_XML
END_NODE_XML

NODE_XML(ObjCInterfaceType, "ObjCInterfaceType")
  ID_ATTRIBUTE_XML
END_NODE_XML

NODE_XML(ObjCObjectPointerType, "ObjCObjectPointerType")
  ID_ATTRIBUTE_XML
END_NODE_XML


//===----------------------------------------------------------------------===//
#undef NODE_XML
#undef ID_ATTRIBUTE_XML                
#undef TYPE_ATTRIBUTE_XML
#undef CONTEXT_ATTRIBUTE_XML
#undef ATTRIBUTE_XML
#undef ATTRIBUTE_OPT_XML
#undef ATTRIBUTE_ENUM_XML
#undef ATTRIBUTE_ENUM_OPT_XML
#undef ENUM_XML
#undef END_ENUM_XML                    
#undef END_NODE_XML                    
